package com.rocker.graduation.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rocker.graduation.dao.DistrictMapper;
import com.rocker.graduation.domain.District;
import com.rocker.graduation.domain.DistrictExample;
import com.rocker.graduation.service.IDistrictService;
import com.rocker.graduation.util.BaseUtils;

@Service
public class DistrictService implements IDistrictService {
	
	@Autowired
	private DistrictMapper districtMapper;
	
	/* (non-Javadoc)
	 * @see com.rocker.graduation.service.impl.IDistrictService#getDistrictById(java.lang.String)
	 */
	@Override
	public String getDistrictById(String cid){
		DistrictExample example = new DistrictExample();
		example.createCriteria().andTypeEqualTo(cid);
		List<District> districts = districtMapper.selectByExample(example);
		return BaseUtils.appendOptions(districts);
	}
	/* (non-Javadoc)
	 * @see com.rocker.graduation.service.impl.IDistrictService#getStateById(java.lang.String)
	 */
	@Override
	public String getStateById(String cid){
		DistrictExample example = new DistrictExample();
		example.createCriteria().andTypeEqualTo(cid);
		List<District> districts = districtMapper.selectByExample(example);
		return BaseUtils.appendState(districts);
	}
	
	/* (non-Javadoc)
	 * @see com.rocker.graduation.service.impl.IDistrictService#getCityById(java.lang.String)
	 */
	@Override
	public String getCityById(String cid){
		DistrictExample example = new DistrictExample();
		example.createCriteria().andParentEqualTo(cid);
		List<District> districts = districtMapper.selectByExample(example);
		return BaseUtils.appendCity(districts);
	}
}
